<template>
  <div class="page">
    <div class="createForm p20">
      <el-form ref="form" :model="pageAjax.data" :inline="true">
        <div class="c-floor">
          <div class="c-head"></div>
          <div class="c-body">
            <div class="c-chunk">
              <div class="c-subheading">
                主播信息
              </div>
              <div class="c-section">
                <el-form-item label="主播姓名：">
                  {{ pageAjax.data.anchor.realName || "无" }}
                </el-form-item>
                <el-form-item label="主播昵称：">
                  {{ pageAjax.data.anchor.nickName || "无" }}
                </el-form-item>
                <el-form-item label="证件类型：">
                  {{
                    translate.certType[pageAjax.data.anchor.certType] || "无"
                  }}
                </el-form-item>
                <el-form-item label="身份证号码：">
                  {{ pageAjax.data.anchor.idCard || "无" }}
                </el-form-item>
                <el-form-item label="联系电话：">
                  {{ pageAjax.data.anchor.contractPhone || "无" }}
                </el-form-item>
                <el-form-item label="邮箱：">
                  {{ pageAjax.data.anchor.email || "无" }}
                </el-form-item>
                <el-form-item label="微信号：">
                  {{ pageAjax.data.anchor.wxNo || "无" }}
                </el-form-item>
                <el-form-item label="地址：">
                  {{ pageAjax.data.anchor.address || "无" }}
                </el-form-item>
                <el-form-item label="主播状态：">
                  {{
                    translate.realSignStatus[
                      pageAjax.data.anchor.contractStatus
                    ] || "无"
                  }}
                </el-form-item>
              </div>
            </div>
            <div class="c-chunk">
              <div class="c-subheading">
                现直播平台
              </div>
              <div class="c-section">
                <el-form-item label="直播平台：">
                  <span
                    class="mr20"
                    v-for="item in translateData(
                      pageAjax.data.liveExperience.platformId,
                      $store.state.wantPlatformList
                    )"
                    :key="item.id"
                    >{{ item.name }}</span
                  >
                </el-form-item>
                <el-form-item label="直播id：">
                  {{ pageAjax.data.liveExperience.liveId || "无" }}
                </el-form-item>
                <el-form-item label="YY号(YY平台专属)：">
                  {{ pageAjax.data.liveExperience.yyAccount || "无" }}
                </el-form-item>
                <el-form-item label="所属运营：">
                  <!-- <el-input
                    placeholder="所属运营"
                    v-model="pageAjax.data.liveExperience.operatorId"
                  >
                  </el-input> -->
                  <el-select
                    v-model="pageAjax.data.liveExperience.operatorId"
                    filterable
                    remote
                    reserve-keyword
                    disabled
                    placeholder="请搜索选择所属运营"
                    :remote-method="rAgentSearch"
                    :loading="agentSearchCp.config.loading"
                  >
                    <el-option
                      v-for="item in agentSearchCp.data"
                      :key="item.userId"
                      :label="item.nickName"
                      :value="item.userId + ''"
                    ></el-option>
                    <!-- <el-option label="运营1" value="1"></el-option>
                      <el-option label="运营2" value="4"></el-option> -->
                  </el-select>
                </el-form-item>
                <el-form-item label="所属招募：">
                  <el-select
                    v-model="pageAjax.data.liveExperience.recruitId"
                    filterable
                    remote
                    disabled
                    reserve-keyword
                    placeholder="请搜索选择所属招募"
                    :remote-method="rSeestarSearch"
                    :loading="seestarSearchCp.config.loading"
                  >
                    <el-option
                      v-for="item in seestarSearchCp.data"
                      :key="item.userId"
                      :label="item.realName"
                      :value="item.userId + ''"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </div>
          </div>
        </div>
        <div class="c-floor">
          <div class="c-head">
            <div class="c-headingExtra clearfix">
              <div class="c-heading fl">
                合同信息
              </div>
            </div>
          </div>
          <div class="c-body">
            <el-tabs
              type="card"
              v-if="pageAjax.data.contractList.length"
              v-model="tabsCp.data.value"
            >
              <el-tab-pane
                :label="item.contractName || '无'"
                :name="'pane' + index"
                v-for="(item, index) in pageAjax.data.contractList"
                :key="index"
              >
                <div
                  class="c-chunk"
                >
                  <!-- <div class="c-subheadingExtra clearfix">
                    <div class="c-subheading fl">
                      合同{{index + 1}}
                    </div>
                  </div> -->

                  <div class="c-section">
                    <div class="c-piece">
                      <el-form-item label="合同名称：">
                        {{
                          pageAjax.data.contractList[index].contractName || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="合同类别：">
                        {{
                          translate.agreementCate[
                            pageAjax.data.contractList[index].contractClass
                          ] || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="合同编号：">
                        {{
                          pageAjax.data.contractList[index].contractNo || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="签约公司(甲方)：">
                        {{
                          pageAjax.data.contractList[index].firstParty || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="签约日期：">
                        {{ pageAjax.data.contractList[index].signDate || "无" }}
                      </el-form-item>
                      <el-form-item label="合作期限：">
                        {{
                          pageAjax.data.contractList[index].signPeriod || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="开始时间：">
                        {{
                          pageAjax.data.contractList[index].contractStartDate ||
                            "无"
                        }}
                      </el-form-item>
                      <el-form-item label="终止时间：">
                        {{
                          pageAjax.data.contractList[index].contractEndDate ||
                            "无"
                        }}
                      </el-form-item>
                      <el-form-item label="保底金额(保底合同)：">
                        {{
                          pageAjax.data.contractList[index].guaranteeAmount ||
                            "无"
                        }}
                      </el-form-item>
                      <el-form-item label="底薪金额(底薪合同)：">
                        {{
                          pageAjax.data.contractList[index].baseSalary || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="签约金额：">
                        {{
                          pageAjax.data.contractList[index].signAmount || "无"
                        }}
                      </el-form-item>
                      <div
                        style="line-height: 40px;display:inline-block;margin-right: 10px;"
                      >
                        <el-form-item label="每月直播有效时长：不低于">
                          {{
                            pageAjax.data.contractList[index]
                              .monthValidBroadcastTime
                          }}
                        </el-form-item>
                        <el-form-item label="小时 且 不低于">
                          {{
                            pageAjax.data.contractList[index]
                              .monthValidBroadcastDay
                          }}
                        </el-form-item>
                        <span style="margin-left: -5px;">天</span>
                      </div>
                      <el-form-item label="流程号：">
                        {{
                          pageAjax.data.contractList[index].processId || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="合同位置：">
                        {{
                          pageAjax.data.contractList[index].contractPos || "无"
                        }}
                      </el-form-item>
                    </div>
                    <div class="c-piece">
                      <div class="c-title">
                        收款账户信息
                      </div>
                      <el-form-item label="开户名：">
                        {{
                          pageAjax.data.contractList[index].receiveAccount
                            .accountName || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="开户银行：">
                        {{
                          pageAjax.data.contractList[index].receiveAccount
                            .accountBank || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="开户账号：">
                        {{
                          pageAjax.data.contractList[index].receiveAccount
                            .account || "无"
                        }}
                      </el-form-item>
                    </div>
                    <div class="c-piece">
                      <div class="c-title">
                        经纪转让权信息
                      </div>
                      <el-form-item label="转让公司：">
                        {{
                          pageAjax.data.contractList[index].brokerTransfer
                            .transferCorp || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="法定代表人：">
                        {{
                          pageAjax.data.contractList[index].brokerTransfer
                            .legalName || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="联系电话：">
                        {{
                          pageAjax.data.contractList[index].brokerTransfer
                            .contractPhone || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="地址：">
                        {{
                          pageAjax.data.contractList[index].brokerTransfer
                            .address || "无"
                        }}
                      </el-form-item>
                      <div class="c-subtitle">
                        收款账户信息(转让公司)
                      </div>
                      <el-form-item label="开户名：">
                        {{
                          pageAjax.data.contractList[index].brokerTransfer
                            .receiveAccount.accountName || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="开户银行：">
                        {{
                          pageAjax.data.contractList[index].brokerTransfer
                            .receiveAccount.accountBank || "无"
                        }}
                      </el-form-item>
                      <el-form-item label="开户账号：">
                        {{
                          pageAjax.data.contractList[index].brokerTransfer
                            .receiveAccount.account || "无"
                        }}
                      </el-form-item>
                    </div>
                    <div class="c-piece">
                      <div class="c-title">
                        设备补充协议(设备扶持专属)
                      </div>
                      <div class="clearfix">
                        <span class="fl c-subtitle mr20">设备清单</span>
                      </div>
                      <el-table
                        :data="
                          pageAjax.data.contractList[index].equipmentAgreement
                            .equipments
                        "
                        style="width: 100%"
                      >
                        <el-table-column label="序号">
                          <template slot-scope="scope">
                            {{ scope.$index + 1 }}
                            <!-- <el-input placeholder="序号" v-model="pageAjax.data.contractList[index].equipmentAgreement.equipments[scope.$index].no">
                            </el-input> -->
                          </template>
                        </el-table-column>
                        <el-table-column label="设备名称">
                          <template slot-scope="scope">
                            {{
                              pageAjax.data.contractList[index]
                                .equipmentAgreement.equipments[scope.$index]
                                .name || scope.$index
                            }}
                          </template>
                        </el-table-column>
                        <el-table-column label="数量">
                          <template slot-scope="scope">
                            {{
                              pageAjax.data.contractList[index]
                                .equipmentAgreement.equipments[scope.$index]
                                .num || "无"
                            }}
                          </template>
                        </el-table-column>
                        <el-table-column label="价格">
                          <template slot-scope="scope">
                            {{
                              pageAjax.data.contractList[index]
                                .equipmentAgreement.equipments[scope.$index]
                                .price || "无"
                            }}
                          </template>
                        </el-table-column>
                      </el-table>
                      <div class="mt20">
                        <el-form-item label="税后总价：">
                          {{
                            pageAjax.data.contractList[index].equipmentAgreement
                              .totalAfterTax || "无"
                          }}
                        </el-form-item>
                        <el-form-item label="交付地点：">
                          {{
                            pageAjax.data.contractList[index].equipmentAgreement
                              .placeOfDelivery || "无"
                          }}
                        </el-form-item>
                        <el-form-item label="交付方式：">
                          {{
                            pageAjax.data.contractList[index].equipmentAgreement
                              .deliveryMode || "无"
                          }}
                        </el-form-item>
                      </div>
                      <div class="mt20">
                    <el-form-item label="设备扶持方式：">
                      {{pageAjax.data.contractList[index].equipmentAgreement
                            .equipmentWay}}
                    </el-form-item>
                    <template
                      v-if="
                        pageAjax.data.contractList[index].equipmentAgreement
                          .equipmentWay == '租赁'
                      "
                    >
                      <el-form-item label="租赁期限：">
                        {{pageAjax.data.contractList[index].equipmentAgreement
                              .rentLimit}}月
                      </el-form-item>
                      <el-form-item label="租赁开始时间：">
                        {{pageAjax.data.contractList[index].equipmentAgreement
                              .rentBeginTime}}
                      </el-form-item>
                      <el-form-item label="租赁终止时间：">
                        {{pageAjax.data.contractList[index].equipmentAgreement
                              .rentEndTime}}
                      </el-form-item>
                      <el-form-item label="月租费用：">
                        </el-input>
                        {{pageAjax.data.contractList[index].equipmentAgreement
                              .rentMoney}}元
                      </el-form-item>
                    </template>
                  </div>
                    </div>
                    <div class="c-piece">
                      <div class="c-title">
                        推广费用刷币(推广扶持专属)
                      </div>
                      <div class="">
                        <el-form-item label="投入金额：">
                          {{
                            pageAjax.data.contractList[index].promotionCost
                              .investAmount || "无"
                          }}
                        </el-form-item>
                        <el-form-item label="返还金额：">
                          {{
                            pageAjax.data.contractList[index].promotionCost
                              .refundAmount || "无"
                          }}
                        </el-form-item>
                      </div>
                    </div>
                    <div class="c-piece">
                      <div class="c-title">
                        星探合作协议(星探合作专属)
                      </div>
                      <div class="clearfix">
                        <span class="fl c-subtitle">星探收款账户信息</span>
                      </div>
                      <div class="">
                        <el-form-item label="开户名：">
                          {{
                            pageAjax.data.contractList[index].scoutAgreement
                              .accountName || "无"
                          }}
                        </el-form-item>
                        <el-form-item label="开户银行：">
                          {{
                            pageAjax.data.contractList[index].scoutAgreement
                              .accountBank || "无"
                          }}
                        </el-form-item>
                        <el-form-item label="银行账号：">
                          {{
                            pageAjax.data.contractList[index].scoutAgreement
                              .account || "无"
                          }}
                        </el-form-item>
                        <el-form-item label="合作费用总额：">
                          {{
                            pageAjax.data.contractList[index].scoutAgreement
                              .totalAmount || "无"
                          }}
                        </el-form-item>
                      </div>
                    </div>
                    <div class="c-piece c-piece-iNote">
                      <div class="c-title clearfix">
                        备注：
                      </div>
                      <div class="c-section">
                        <el-form-item class="block">
                          {{ pageAjax.data.contractList[index].remark || "无" }}
                        </el-form-item>
                      </div>
                    </div>
                    <div class="c-piece">
                      <div class="c-title clearfix">
                        <span class="fl">合同照片</span>
                        <!-- <el-button type="primary" plain class="btn fl c-btnCreate" size="mini"
                          >上传pdf合同</el-button> -->
                        <!-- <el-upload
                            class="diy-uploadBtn fl"
                            :action="uploadPdfAjax.config.url"
                            :headers="uploadPdfAjax.config.headers"
                            :multiple="false"
                            ref="uploadPdf"
                            accept=".pdf"
                            :show-file-list="false"
                            :disabled="uploadPdfAjax.config.disabled"
                            :on-success="rUploadPdfSuc(index)"
                            :on-error="rUploadPdfFail(index)"
                            :before-upload="rUploadPdfBefore(index)"
                            :limit="1">
                            <el-button type="primary" plain class="btn" size="mini">上传pdf合同</el-button>
                          </el-upload> -->
                      </div>
                      <div class="mi-upload">
                        <div class="m-files">
                          <div class="m-preview clearfix">
                            <div
                              class="m-file"
                              v-for="(picsItem, picsIndex) in pageAjax.data
                                .contractList[index].contractPics"
                              :key="picsIndex"
                            >
                              <img :src="picsItem" alt="" />
                              <!-- <i class="el-icon-delete" @click="rDeletePic(index, picsIndex)"></i> -->
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </el-tab-pane>
            </el-tabs>
          </div>
        </div>
        <el-form-item class="tc block">
          <el-button
            type="primary"
            plain
            class="btn"
            size="middle"
            @click="rBack"
            >返回</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { getUserData, getUserInfoEveryOne } from "@/api/user.js";
import { getAgreementAgentInfo } from "@/api/actor.js";
import { selectData } from "@/assets/js/util.js";
import _ from "lodash";

export default {
  name: "lawyer_agreementDetail",
  data: () => ({
    pageAjax: {
      loading: false,
      data: {
        anchor: {
          realName: "",
          nickName: "",
          idCard: "",
          contractPhone: "",
          email: "",
          wxNo: "",
          address: "",
          signStatus: ""
        },
        liveExperience: {
          platformId: "",
          liveId: "",
          yyAccount: "",
          operatorId: "",
          recruitId: ""
        },
        contractList: []
      },
      rules: {}
    },
    alone: {
      uploadPdfIndex: 0,
      realSignStatus: [
        {
          name: "在约",
          value: "SIGNING"
        },
        {
          name: "解约",
          value: "RESCISSION"
        }
      ],
      agreementCate: [
        {
          name: "艺人演艺经纪合同（保底）",
          value: "bottom_guard"
        },
        {
          name: "艺人演艺经纪合同（底薪费用）",
          value: "base_salary"
        },
        {
          name: "艺人演艺经纪合同（签约金）",
          value: "sign_money"
        },
        {
          name: "主播经纪权转让协议",
          value: "broker_transfer"
        },
        {
          name: "推广扶持协议",
          value: "promotion"
        },
        {
          name: "星探合作协议",
          value: "scout_agreement"
        },
        {
          name: "设备补充协议",
          value: "equipment_agreement"
        },
        {
          name: "互联网演艺经纪合同（直播约",
          value: "network_live"
        },
        {
          name: "金牌合同",
          value: "jp_contract"
        },
        {
          name: "其他",
          value: "other"
        }
      ],
      userType: "",
      agreementFormwork: {
        contractName: "",
        contractClass: "",
        contractNo: "",
        firstParty: "",
        signDate: "",
        signPeriod: "",
        contractStartDate: "",
        contractEndDate: "",
        guaranteeAmount: "",
        baseSalary: "",
        signAmount: "",
        processId: "",
        contractPos: "",
        receiveAccount: {
          accountName: "",
          accountBank: "",
          account: ""
        },
        brokerTransfer: {
          transferCorp: "",
          legalName: "",
          contractPhone: "",
          address: "",
          receiveAccount: {
            accountName: "",
            accountBank: "",
            account: ""
          }
        },
        equipmentAgreement: {
          totalAfterTax: "",
          placeOfDelivery: "",
          deliveryMode: "",
          equipments: []
        },
        promotionCost: {
          investAmount: "",
          refundAmount: ""
        },
        scoutAgreement: {
          accountName: "",
          accountBank: "",
          account: "",
          totalAmount: "",
          remark: ""
        },
        contractPics: []
      }
    },
    translate: {
      certType: {
        "00": "身份证",
        "01": "护照",
        "02": "港澳通行证",
        "05": "港澳同胞回乡证",
        "99": "其他"
      },
      realSignStatus: {
        SIGNING: "在约",
        RESCISSION: "解约"
      },
      agreementCate: {
        bottom_guard: "艺人演艺经纪合同（保底）",
        base_salary: "艺人演艺经纪合同（底薪费用）",
        sign_money: "艺人演艺经纪合同（签约金）",
        broker_transfer: "主播经纪权转让协议",
        promotion: "推广扶持协议",
        scout_agreement: "星探合作协议",
        equipment_agreement: "设备补充协议",
        other: "其他"
      }
    },
    agentSearchCp: {
      config: {
        loading: false
      },
      first: false, // 进入页面请求所属运营
      data: []
    },
    seestarSearchCp: {
      config: {
        loading: false
      },
      first: false, // 进入页面请求所属招募
      data: []
    },
    tabsCp: {
      data: {
        value: "pane0"
      }
    },
    uploadPdfAjax: {
      loading: false,
      config: {
        disabled: false,
        headers: {
          Authorization: ""
        },
        url: "/bs/anchor/contract/importPdf"
      }
    }
  }),
  watch: {
    "pageAjax.data": function() {
      let _that = this;
      if (
        !_that.seestarSearchCp.first &&
        _that.pageAjax.data.liveExperience.recruitId
      ) {
        _that.seestarSearchCp.first = true;
        _that.getUserInfo(
          _that.pageAjax.data.liveExperience.recruitId,
          "RECRUIT"
        );
      }
      if (
        !_that.agentSearchCp.first &&
        _that.pageAjax.data.liveExperience.operatorId
      ) {
        _that.agentSearchCp.first = true;
        _that.getUserInfo(
          _that.pageAjax.data.liveExperience.operatorId,
          "OPERATOR"
        );
      }
    }
  },
  created() {
    let _that = this;
    _that.getPageData();
    // _that.getUserData('OPERATOR');
    //
    // _that.getUserData('RECRUIT', );

    _that.uploadPdfAjax.config.headers.Authorization =
      "bearer " + _that.$store.state.sid.access_token;
  },
  methods: {
    rAgentSearch() {
      let _that = this;

      _that.alone.userType = "OPERATOR";
      _that.getUserData();
    },
    rSeestarSearch() {
      let _that = this;
      _that.alone.userType = "RECRUIT";
      _that.getUserData();
    },
    rAddAgreement() {
      let _that = this;
      let agreementFormwork = _.cloneDeep(_that.alone.agreementFormwork);
      _that.pageAjax.data.contractList.push(agreementFormwork);
    },
    rDeleteAgreement(index) {
      this.pageAjax.data.contractList.splice(index, 1);
    },
    rAddDeviceRecord(index) {
      let _that = this;
      let formwork = {
        no: "",
        name: "",
        num: "",
        price: ""
      };
      _that.pageAjax.data.contractList[
        index
      ].equipmentAgreement.equipments.push(formwork);
    },
    rDeleteDeviceRecord(index, i) {
      this.pageAjax.data.contractList[
        index
      ].equipmentAgreement.equipments.splice(i, 1);
    },
    rDeletePic(index, i) {
      this.pageAjax.data.contractList[index].pics.splice(i, 1);
    },
    rUploadPdfSuc(respData) {
      let _that = this;
      _that.uploadPdfAjax.config.disabled = false;
      _that.uploadPdfAjax.loading.close();
      let data = respData.data || {};
      _that.clearFiles();
      if (respData.code === _that.STATUS.success[0]) {
        _that.resetPageAjaxData(data);
        // _that.pageAjax.data.anchor =  _.merge(pageAjaxData.anchor, respData.data.anchor);
        // _that.pageAjax.data.contractList[uploadPdfIndex] = _.merge(respData.data.contractList[0], pageAjaxData.contractList[uploadPdfIndex])
        // console.log('respData', respData, _that.pageAjax)
        // _that.pageAjax.paging.current = 0;
        // _that.getPageData();
      } else {
        _that.$message.error({
          message: respData.msg || "上传失败"
        });
      }
    },
    rUploadPdfFail() {
      let _that = this;
      _that.uploadPdfAjax.loading.close();
      _that.uploadPdfAjax.config.disabled = false;
      _that.clearFiles();
      _that.$message.error({
        message: "上传错误，请查看网络或联系管理员"
      });
    },
    rUploadPdfBefore() {
      this.uploadPdfAjax.loading = this.$loading({
        text: "上传中。。。",
        lock: true
      });
    },
    rUploadPdfProgress() {},
    resetPageAjaxData(data) {
      let _that = this;
      let pageAjaxData = _.cloneDeep(_that.pageAjax.data);
      let uploadPdfIndex = _that.alone.uploadPdfIndex;
      let anchor = data.anchor || {};
      let liveExperience = data.liveExperience || {};
      let contract = data.contractList[0] || {};
      // _that.pageAjax.data.anchor =  _.merge(pageAjaxData.anchor, data.anchor);
      //_that.pageAjax.data.contractList[uploadPdfIndex] = _.merge(data.contractList[0], pageAjaxData.contractList[uploadPdfIndex]);

      // 更新主播信息
      for (let attr in anchor) {
        if (anchor[attr]) {
          pageAjaxData.anchor[attr] = anchor[attr];
        }
      }
      // 更新现直播平台
      for (let attr in liveExperience) {
        if (liveExperience[attr]) {
          pageAjaxData.liveExperience[attr] = liveExperience[attr];
        }
      }
      // 更新合同
      for (let attr in contract) {
        // 收款账户信息
        if (attr === "receiveAccount" && contract[attr]) {
          for (let attrOne in contract[attr]) {
            if (contract[attr][attrOne]) {
              pageAjaxData.contractList[uploadPdfIndex][attr][attrOne] =
                contract[attr][attrOne];
            }
          }
        } else if (attr === "brokerTransfer" && contract[attr]) {
          for (let attrOne in contract[attr]) {
            if (attrOne === "receiveAccount" && contract[attr][attrOne]) {
              for (let attrTwo in contract[attr][attrOne]) {
                if (contract[attr][attrOne][attrTwo]) {
                  pageAjaxData.contractList[uploadPdfIndex][attr][attrOne][
                    attrTwo
                  ] = contract[attr][attrOne][attrTwo];
                }
              }
            } else {
              if (contract[attr][attrOne]) {
                pageAjaxData.contractList[uploadPdfIndex][attr][attrOne] =
                  contract[attr][attrOne];
              }
            }
          }
        } else if (attr === "equipmentAgreement" && contract[attr]) {
          for (let attrOne in contract[attr]) {
            if (attrOne === "equipments" && contract[attr][attrOne]) {
              for (let attrTwo in contract[attr][attrOne]) {
                if (contract[attr][attrOne][attrTwo]) {
                  pageAjaxData.contractList[uploadPdfIndex][attr][attrOne][
                    attrTwo
                  ] = contract[attr][attrOne][attrTwo];
                }
              }
            } else {
              if (contract[attr][attrOne]) {
                pageAjaxData.contractList[uploadPdfIndex][attr][attrOne] =
                  contract[attr][attrOne];
              }
            }
          }
        } else if (attr === "promotionCost" && contract[attr]) {
          for (let attrOne in contract[attr]) {
            if (contract[attr][attrOne]) {
              pageAjaxData.contractList[uploadPdfIndex][attr][attrOne] =
                contract[attr][attrOne];
            }
          }
        } else if (attr === "scoutAgreement" && contract[attr]) {
          for (let attrOne in contract[attr]) {
            if (contract[attr][attrOne]) {
              pageAjaxData.contractList[uploadPdfIndex][attr][attrOne] =
                contract[attr][attrOne];
            }
          }
        } else if (attr === "contractPics" && contract[attr]) {
          for (let attrOne in contract[attr]) {
            if (contract[attr][attrOne]) {
              pageAjaxData.contractList[uploadPdfIndex][attr][attrOne] =
                contract[attr][attrOne];
            }
          }
        } else {
          if (contract[attr]) {
            pageAjaxData.contractList[uploadPdfIndex][attr] = contract[attr];
          }
        }
      }

      _that.pageAjax.data = pageAjaxData;
    },
    clearFiles() {
      let _that = this;
      for (var i = _that.$refs.uploadPdf.length; i--; ) {
        _that.$refs.uploadPdf[i].clearFiles();
      }
    },
    rUploadClick(index) {
      this.alone.uploadPdfIndex = index;
    },
    rBack() {
      this.$router.go(-1);
    },
    translateData(arr, arrList) {
      let a = selectData(arr, arrList);
      return a;
    },

    getUserData(type) {
      let _that = this;
      let userType = type || _that.alone.userType;

      if (
        _that.agentSearchCp.config.loading ||
        _that.seestarSearchCp.config.loading
      ) {
        return;
      }

      if (userType == "RECRUIT") {
        _that.seestarSearchCp.config.loading = true;
      } else {
        _that.agentSearchCp.config.loading = true;
      }
      getUserData({ params: { role: userType } })
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            if (userType == "RECRUIT") {
              _that.seestarSearchCp.data = respData.data.list;
            } else {
              _that.agentSearchCp.data = respData.data.list;
            }
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {
          _that.seestarSearchCp.config.loading = _that.agentSearchCp.config.loading = false;
        });
    },
    getUserInfo(id, userType) {
      let _that = this;
      getUserInfoEveryOne({ params: { userId: id } }).then(resp => {
        let respData = resp.data || {};
        if (respData.code === _that.STATUS.success[0]) {
          if (userType == "RECRUIT") {
            _that.seestarSearchCp.data.push(respData.data);
          } else {
            _that.agentSearchCp.data.push(respData.data);
            // _that.agentSearchCp.config.loading = true;
          }
          // _that.userInfo.agent = respData.data;
        } else {
          _that.$message.error(respData.msg || "获取失败");
        }
      });
    },
    getPageData() {
      let _that = this;
      let agreementFormwork = _.cloneDeep(_that.alone.agreementFormwork);
      
      getAgreementAgentInfo({
        params: { anchorId: _that.$route.query.anchorId }
      })
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            // _that.pageAjax.data = respData.data;
            let respResult = respData.data;
            if (respResult.contractList) {
              respResult.contractList.map(item => {
                if (!item.receiveAccount) {
                  item.receiveAccount = _.cloneDeep(
                    agreementFormwork.receiveAccount
                  );
                }
                if (!item.brokerTransfer) {
                  item.brokerTransfer = _.cloneDeep(
                    agreementFormwork.brokerTransfer
                  );
                }
                if (!item.brokerTransfer.receiveAccount) {
                  item.brokerTransfer.receiveAccount = _.cloneDeep(
                    agreementFormwork.brokerTransfer.receiveAccount
                  );
                }
                return item;
              });
            }

              respResult.liveExperience.platformId =
              respResult.liveExperience.platformId ? respResult.liveExperience.platformId * 1 : '';
            _that.pageAjax.data = respResult;
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {});
    }
  }
};
</script>

<style lang="scss" scoped>
.page {
  .block {
    display: block;
  }
  .c-head {
    margin-top: 20px;
    border-top: 1px solid #f5f7fa;
    line-height: 40px;
    button {
      margin-top: 6px;
    }
  }
  .c-heading {
    height: 40px;
    margin-right: 20px;
    line-height: 40px;
    font-size: 20px;
    color: #ccc;
  }
  .c-subheadingExtra {
    line-height: 40px;
    i {
      margin: 0 20px;
      font-size: 20px;
      color: #ff0000;
    }
  }
  .c-subheading {
    height: 40px;
    line-height: 40px;
    font-size: 18px;
    color: #000;
  }
  .c-title {
    height: 40px;
    line-height: 40px;
    font-size: 16px;
    color: #000;
  }
  .c-subtitle {
    line-height: 30px;
  }
  .c-chunk {
    border-bottom: 1px solid #f3f3f3;
  }
  .c-btnCreate {
    margin-top: 8px;
    margin-left: 10px;
  }

  .mi-upload {
    padding: 20px;
    .mi-title {
      margin-bottom: 20px;
    }
    .m-files {
    }
    .m-file {
      position: relative;
      float: left;
      width: 150px;
      height: 150px;
      margin-right: 10px;
      margin-bottom: 10px;
      border: 1px solid #ebeef5;
      box-sizing: border-box;
      img,
      video {
        display: block;
        width: 100%;
        height: 100%;
      }
      &:hover .m-operation {
        opacity: 1;
      }
    }
    .m-operation {
      opacity: 0;
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.4);
      color: #fff;
      transition: opacity 0.4s;
      i {
        font-size: 20px;
        padding: 10px 20px;
      }
    }
  }
}
</style>
<style lang="scss">
.page {
  .c-piece-iNote {
    .el-form-item__content {
      width: 100%;
    }
  }
}
</style>
